home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Information / CSMP Digest / volume 3 / csmp-digest-v3-096 < prev    next >
Text File  |  1995-12-31  |  61KB  |  1,623 lines

  1. C.S.M.P. Digest             Wed, 03 May 95       Volume 3 : Issue 96
  2.  
  3. Today's Topics:
  4.  
  5.         Drawing with VBL interrupts?
  6.         Is Delay() defunct?
  7.         Looking for advice on a jGNEFilter...
  8.         NEW DEVELOPMENT ARCHIVE at AMUG!
  9.         Problem drawing PICT with QT (-8976!?)
  10.         QuickTime & MPEG-Streams?
  11.         Speeding up NewPtr
  12.         Where is the QTv2.0 header file?
  13.         [MINI FAQ] Programming with MacTCP
  14.         [Q] Temporary Files
  15.         [Q] Where is the stack?
  16.  
  17.  
  18.  
  19. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  20. (pottier@clipper.ens.fr).
  21.  
  22. The digest is a collection of article threads from the internet newsgroup
  23. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  24. regularly and want an archive of the discussions.  If you don't know what a
  25. newsgroup is, you probably don't have access to it.  Ask your systems
  26. administrator(s) for details.  If you don't have access to news, you may
  27. still be able to post messages to the group by using a mail server like
  28. anon.penet.fi (mail help@anon.penet.fi for more information).
  29.  
  30. Each issue of the digest contains one or more sets of articles (called
  31. threads), with each set corresponding to a 'discussion' of a particular
  32. subject.  The articles are not edited; all articles included in this digest
  33. are in their original posted form (as received by our news server at
  34. nef.ens.fr).  Article threads are not added to the digest until the last
  35. article added to the thread is at least two weeks old (this is to ensure that
  36. the thread is dead before adding it to the digest).  Article threads that
  37. consist of only one message are generally not included in the digest.
  38.  
  39. The digest is officially distributed by two means, by email and ftp.
  40.  
  41. If you want to receive the digest by mail, send email to listserv@ens.fr
  42. with no subject and one of the following commands as body:
  43.     help                                Sends you a summary of commands
  44.     subscribe csmp-digest Your Name     Adds you to the mailing list
  45.     signoff csmp-digest                 Removes you from the list
  46. Once you have subscribed, you will automatically receive each new
  47. issue as it is created.
  48.  
  49. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  50. Questions related to the ftp site should be directed to
  51. scott.silver@dartmouth.edu.
  52.  
  53. -------------------------------------------------------
  54.  
  55. >From els3339@is.nyu.edu (Eric L. Singer)
  56. Subject: Drawing with VBL interrupts?
  57. Date: 9 Apr 1995 20:30:15 GMT
  58. Organization: New York University
  59.  
  60.  
  61. I am trying to do pict drawing using the vertical refresh interrupt (VBL) 
  62. to eliminate screen flicker during animation.
  63.  
  64. I had originally tried building a queue of info for CopyBits requests and
  65. then drawing them during the VBL interrupt by dequeuing the info and
  66. calling CopyBits for each request. 
  67.  
  68. The problem is that CopyBits can call the memory manager and move memory 
  69. - a no-no during interrupt processing.
  70.  
  71. Can anyone suggest a better way to do this?
  72.  
  73. Thanks,
  74. Eric Singer
  75.  
  76.  
  77.  
  78. +++++++++++++++++++++++++++
  79.  
  80. >From Ed Wynne <arwyn@engin.umich.edu>
  81. Date: 11 Apr 1995 17:52:43 GMT
  82. Organization: The University of Michigan
  83.  
  84. In article <fdj-1004951826020001@fdj.muc.de> Florian -FDj- Dejako,
  85. fdj@muc.de writes:
  86. >Don't do QuickDraw stuff during VBLs. In general, synching animations by
  87. >VBL tasks isn't a good idea at all. QuickTime doesn't do it, and it
  88. >doesn't flicker. You shouldn't do it either. Better avoid redrawing areas
  89. >on the screen twice etc... There are a couple of tricks that can help you
  90. >avoid flicker.
  91. >
  92.  
  93. QuickTime doesn't do it, and it doesn't flicker...it tears...quite
  94. noticeably
  95. sometimes.  There is absolutely nothing wrong with syncing animations to a
  96. VBL interval, the no-no is drawing at interrupt time.  Instead you should
  97. use
  98. a VBL task to set a global whenever the VBL interval hits.  (Make sure
  99. your
  100. using SlotVInstall to get the VBL you think your getting...)  Your main
  101. drawing
  102. loop should be waiting for this global to change, and when it does it
  103. should
  104. then start redrawing...at non-interrupt time.
  105.  
  106. -ed
  107.  
  108. +++++++++++++++++++++++++++
  109.  
  110. >From Hiep Dam <starlabs@delphi.com>
  111. Date: Wed, 12 Apr 95 03:02:10 -0500
  112. Organization: Delphi (info@delphi.com email, 800-695-4005 voice)
  113.  
  114. Eric L. Singer <els3339@is.nyu.edu> writes:
  115.  
  116. >I am trying to do pict drawing using the vertical refresh interrupt (VBL) 
  117. >to eliminate screen flicker during animation.
  118.  
  119. Well, you shouldn't call CopyBits (as you said). I believe the normal way is
  120. to set a flag in your interrupt, and have a loop somewhere to check for this
  121. flag. If it's set, then call your CopyBits routine (and don't forget to reset
  122. your flag after CopyBitsing) from this loop. Voila!
  123.  
  124. As an aside, IMHO you shouldn't use VBL interrupts to do animations. Use the
  125. Time Manager instead; different monitors have different refresh rates, so
  126. you might end up with different animation rates on different monitors, not to
  127. mention using the VBL is more likely to become "sticky"...
  128.  
  129. Did I mention GWorlds? That and the Time manager should suit you fine...
  130.  
  131. --Hiep
  132.  
  133. +++++++++++++++++++++++++++
  134.  
  135. >From sherman1+@pitt.edu (Sherman Uitzetter)
  136. Date: Wed, 12 Apr 1995 16:46:22 +0100
  137. Organization: University of Pittsburgh
  138.  
  139.  
  140. In article <pS5+g5S.starlabs@delphi.com>, Hiep Dam <starlabs@delphi.com> wrote:
  141. > As an aside, IMHO you shouldn't use VBL interrupts to do animations. Use the
  142. > Time Manager instead; different monitors have different refresh rates, so
  143. > you might end up with different animation rates on different monitors, not to
  144. > mention using the VBL is more likely to become "sticky"...
  145.  
  146. Actually (I believe) VBL interrupts on the Mac occur when the electron beam
  147. is moving from the bottom to the top of the screen on which the interrupt was
  148. "installed".  That is, they ARE synch'd to the refresh rate of the monitor
  149. you install the interrupt to (via SlotVInstall()).
  150.  
  151. If you want to get every ounce of drawing time you can before the next
  152. retrace, use a VBL interrupt AND the Time Manager to wait for the beam to
  153. get just past the area of the screen you're drawing in ;-) (this may not
  154. buy you
  155. too much extra drawing time but it is neat).
  156.  
  157. Hope that made sense,
  158. -Sherman.
  159.  
  160. +++++++++++++++++++++++++++
  161.  
  162. >From afcjlloyd@aol.com (AFC JLloyd)
  163. Date: 12 Apr 1995 21:58:41 -0400
  164. Organization: America Online, Inc. (1-800-827-6364)
  165.  
  166. >In article <pS5+g5S.starlabs@delphi.com>, Hiep Dam <starlabs@delphi.com>
  167. wrote:
  168. >> As an aside, IMHO you shouldn't use VBL interrupts to do animations.
  169. Use the
  170. >> Time Manager instead; different monitors have different refresh rates,
  171. so
  172. >> you might end up with different animation rates on different monitors,
  173. not to
  174. >> mention using the VBL is more likely to become "sticky"...
  175. >
  176. >Actually (I believe) VBL interrupts on the Mac occur when the electron
  177. beam
  178. >is moving from the bottom to the top of the screen on which the interrupt
  179. was
  180. >"installed".  That is, they ARE synch'd to the refresh rate of the
  181. monitor
  182. >you install the interrupt to (via SlotVInstall()).
  183. >
  184. >If you want to get every ounce of drawing time you can before the next
  185. >retrace, use a VBL interrupt AND the Time Manager to wait for the beam to
  186. >get just past the area of the screen you're drawing in ;-) (this may not
  187. >buy you too much extra drawing time but it is neat).
  188.  
  189. I implemented a scheme based upon the above idea.  During initialization,
  190. I used very simple timer and slotvbl tasks to measure, as accurately as
  191. possible, the vbl rate for the chosen monitor.  Based upon this
  192. information, I set a timer task going at 4 interrupts per slot interrupt. 
  193. I kept a very simple slot interrupt running just to make sure that my
  194. timer interrupt didn't drift.  All blittling was done from the timer
  195. interrupt, and was scheduled such that pixels where always blitted to the
  196. screen in areas where the electron beam could not possibly be.
  197.  
  198. The program is a juggling pattern animator, and animates complicated
  199. juggling patterns: 3-9 balls (for a two-handed juggler, hands not shown),
  200. multiple throw heights, but always a "legal" juggling pattern, i.e. one a
  201. perfectly skilled human juggler could perform without ball collisions, or
  202. ever holding two balls in one hand.  On a 840av the result is stunning. 
  203. The program can show 24-bit, full 3D render balls at the full refresh rate
  204. of the monitor (>60 fps), with absolutely no tearing or flicker.  Even at
  205. better than 60 fps, it turns out that it is necessary to use motion blur
  206. make the animation look right.  Otherwise, balls moving at high velocity
  207. (just after a release, or just before a catch) look strobroscopic.
  208.  
  209. The problem with the above approach is that it's very hard to avoid cursor
  210. droppings.  The basic trick of calling ShieldCursor doesn't seem to work
  211. when ShieldCursor can get called multiple times per frame.   It was also
  212. clear from testing on different platforms that the cursor dropping problem
  213. varied across machines, from which I inferred that any hack to fix it
  214. would possibly have to be different for each version of the ROM/System. 
  215. At this point, it finally sunk in that there were good reasons behind
  216. Apple's warnings to not draw directly to the screen.
  217.  
  218. Of course, it may be that I could make the program work well if I did all
  219. of the blitting from the vbl task, and didn't use the timer task, but when
  220. I next get the urge to work on the program, I think I'll try to rewrite it
  221. to not do any blitting at interrupt time.  It will probably make it easier
  222. to take advantage of native PowerPC code anyway, since interrupt handling
  223. requires a (relatively expensive) mode switch.
  224.  
  225. Jim Lloyd
  226. afcjlloyd@aol.com
  227.  
  228. +++++++++++++++++++++++++++
  229.  
  230. >From kordon@solstice.jpl.nasa.gov (kordon)
  231. Date: 14 Apr 1995 22:47:35 GMT
  232. Organization: Jet Propulsion Laboratory, Pasadena
  233.  
  234. In article <sherman1+-1204951646220001@128.147.45.101>
  235. sherman1+@pitt.edu (Sherman Uitzetter) writes:
  236.  
  237. > you install the interrupt to (via SlotVInstall()).
  238.  
  239. Does anyone know how to get the slot number of the main monitor?
  240.  
  241. - mark -
  242.  
  243. +++++++++++++++++++++++++++
  244.  
  245. >From chris-b@cs.aukuni.ac.nz (Christopher David Burns)
  246. Date: 17 Apr 1995 03:16:13 GMT
  247. Organization: University of Auckland
  248.  
  249. kordon@solstice.jpl.nasa.gov (kordon) writes:
  250.  
  251. >In article <sherman1+-1204951646220001@128.147.45.101>
  252. >sherman1+@pitt.edu (Sherman Uitzetter) writes:
  253.  
  254. >> you install the interrupt to (via SlotVInstall()).
  255.  
  256. >Does anyone know how to get the slot number of the main monitor?
  257.  
  258. TheGDevice = GetMainDevice();
  259. TheDCtlHandle = GetDCtlEntry((**TheGDevice).gdRefNum);
  260. TheAuxDCEPtr = (AuxDCE*)*TheDCtlHandle;
  261. Slot = (*TheAuxDCEPtr).dCtlSlot;
  262.  
  263. Chris B
  264. - ---------------------------------------------------------------------
  265. NewZealand:AucklandUniversity:ComputerScience:HyperMediaUnit:ChrisBurns
  266. Internet: chris-b@cs.auckland.ac.nz
  267. Phone:    +64 9 373-7599 x6194
  268. Fax:      +64 9 373-7453                         Async, therefore I am.
  269. - ---------------------------------------------------------------------
  270.  
  271. +++++++++++++++++++++++++++
  272.  
  273. >From grobbins@znet.com (Grobbins)
  274. Date: Sun, 16 Apr 1995 21:07:33 -0700
  275. Organization: Skunkworks
  276.  
  277. In article <3mmu27$pp@lo-fan.jpl.nasa.gov>, kordon@solstice.jpl.nasa.gov
  278. (kordon) wrote:
  279. >Does anyone know how to get the slot number of the main monitor?
  280.  
  281. >From DTS Tech Note HW 555 (Video Hardware Q&As):
  282.  
  283. void GetSlot(GDHandle gDev,short *slot)
  284. {  
  285.   short    refNum;
  286.  
  287.   refNum = (**gDev).gdRefNum;   // video driver refNum for this GDevice
  288.   *slot = (**(AuxDCEHandle)GetDCtlEntry(refNum)).dCtlSlot;
  289.                    // slot in which this video card sits
  290. }
  291.  
  292.  
  293. Grobbins                grobbins@znet.com
  294.  
  295. ---------------------------
  296.  
  297. >From walkerj@math.scarolina.edu (James W. Walker)
  298. Subject: Is Delay() defunct?
  299. Date: Tue, 04 Apr 1995 19:38:55 -0500
  300. Organization: Dept. of Mathematics, Univ. of South Carolina
  301.  
  302. Toolbox Assistant and the new Inside Mac do not seem to list Delay.  And
  303. if I read OSUtils.h right, Delay is not implemented on the PowerPC.  So,
  304. if Delay is defunct, how am I supposed to indicate a keyboard equivalent
  305. of a button, like:
  306.  
  307. HiliteControl( my_button, inButton );
  308. Delay( 8, &blah );
  309. HiliteControl( my_button, 0 );
  310.  
  311. ?
  312. -- 
  313.  Jim Walker
  314.  
  315. +++++++++++++++++++++++++++
  316.  
  317. >From joelaff@aol.com (JoeLaff)
  318. Date: 5 Apr 1995 00:15:27 -0400
  319. Organization: America Online, Inc. (1-800-827-6364)
  320.  
  321. >>>>Toolbox Assistant and the new Inside Mac do not seem to list Delay. 
  322. And
  323. if I read OSUtils.h right, Delay is not implemented on the PowerPC.  So,
  324. if Delay is defunct, how am I supposed to indicate a keyboard equivalent
  325. of a button, like:
  326.  
  327. HiliteControl( my_button, inButton );
  328. Delay( 8, &blah );
  329. HiliteControl( my_button, 0 );
  330.  
  331. ?
  332. -- 
  333.  Jim Walker
  334. <<<
  335.  
  336. Don't know if Delay is defunct.  I really doubt it, but you could use a
  337. loop that uses some multiple of TimeDBRA. This global variable is supposed
  338. to provide some indication of computer speed (although the latest IM I
  339. read said that it was NOT a good indicator of speed because it could vary
  340. too much). 
  341.  
  342. You could also use a Time Manager Task, but this seems like a lot of
  343. effort to keep your button highlited!!!
  344.  
  345. Joe
  346. Joe <----
  347. ****  E N D    O F    L I N E  ****
  348.  
  349. +++++++++++++++++++++++++++
  350.  
  351. >From wem53067@uxa.cso.uiuc.edu (The Bard)
  352. Date: Wed, 05 Apr 1995 02:46:03 -0600
  353. Organization: Bard 'O Matic Software
  354.  
  355. In article <walkerj-0404951938550001@milo.math.scarolina.edu>,
  356. walkerj@math.scarolina.edu (James W. Walker) wrote:
  357.  
  358. > Toolbox Assistant and the new Inside Mac do not seem to list Delay.  And
  359. > if I read OSUtils.h right, Delay is not implemented on the PowerPC.  So,
  360. > if Delay is defunct, how am I supposed to indicate a keyboard equivalent
  361. > of a button, like:
  362. > HiliteControl( my_button, inButton );
  363. > Delay( 8, &blah );
  364. > HiliteControl( my_button, 0 );
  365.  
  366. I was wondering the same thing after finding it in the headers and not
  367. seing it in Toolbox Assistant. But, I'm on a ppc and I can still call it.
  368. It looks like Delay(x &i) where x and i are integers and x is delay in
  369. system ticks and i contains the last system tick after delay exits...
  370.  
  371. I think this is correct... its working correctly in my ppc code :)
  372.  
  373. Wayde
  374.  
  375. +++++++++++++++++++++++++++
  376.  
  377. >From dlakelan@iastate.edu (Dan Lakeland)
  378. Date: 5 Apr 95 19:29:57 GMT
  379. Organization: Iowa State University, Ames, Iowa
  380.  
  381. In <3lt5gv$cdi@newsbf02.news.aol.com> joelaff@aol.com (JoeLaff) writes:
  382.  
  383. >>>>>Toolbox Assistant and the new Inside Mac do not seem to list Delay. 
  384. >And
  385. >if I read OSUtils.h right, Delay is not implemented on the PowerPC.  So,
  386. >if Delay is defunct, how am I supposed to indicate a keyboard equivalent
  387. >of a button, like:
  388.  
  389. >HiliteControl( my_button, inButton );
  390. >Delay( 8, &blah );
  391. >HiliteControl( my_button, 0 );
  392.  
  393. >?
  394. >-- 
  395. > Jim Walker
  396. ><<<
  397.  
  398. >Don't know if Delay is defunct.  I really doubt it, but you could use a
  399. >loop that uses some multiple of TimeDBRA. This global variable is supposed
  400. >to provide some indication of computer speed (although the latest IM I
  401. >read said that it was NOT a good indicator of speed because it could vary
  402. >too much). 
  403.  
  404. >You could also use a Time Manager Task, but this seems like a lot of
  405. >effort to keep your button highlited!!!
  406.  
  407. I don't know the granularity of Delay, but how about
  408.  
  409. while(TickCount() - prevTicks < TicksToWait)
  410.         ;
  411.  
  412. -- 
  413. Daniel Lakeland: Macintosh Hacker, Mathematics Major, NRA Member.
  414. Macintosh Hacking, an art best learned w/ an axe...
  415. The computer programmer's worst nightmare:
  416. Unwittingly finding compiler bugs.
  417.  
  418. +++++++++++++++++++++++++++
  419.  
  420. >From lsr@taligent.com (Larry Rosenstein)
  421. Date: Wed, 05 Apr 1995 15:50:30 -0700
  422. Organization: Taligent, Inc.
  423.  
  424. In article <3lt5gv$cdi@newsbf02.news.aol.com>, joelaff@aol.com (JoeLaff) wrote:
  425.  
  426. >loop that uses some multiple of TimeDBRA. This global variable is supposed
  427. >to provide some indication of computer speed (although the latest IM I
  428.  
  429. TechNote "PT 39 The DR Emulator" cautions against relying on DBRA for timing.
  430.  
  431. -- 
  432. Larry Rosenstein
  433. Taligent, Inc.
  434.  
  435. lsr@taligent.com
  436.  
  437. +++++++++++++++++++++++++++
  438.  
  439. >From ntoge@netcom.com (Nobukazu Toge)
  440. Date: Thu, 6 Apr 1995 00:45:00 GMT
  441. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  442.  
  443. James W. Walker (walkerj@math.scarolina.edu) wrote:
  444. > Toolbox Assistant and the new Inside Mac do not seem to list Delay.  And
  445. > if I read OSUtils.h right, Delay is not implemented on the PowerPC.  So,
  446. > if Delay is defunct, how am I supposed to indicate a keyboard equivalent
  447. > of a button, like:
  448.  
  449. > HiliteControl( my_button, inButton );
  450. > Delay( 8, &blah );
  451. > HiliteControl( my_button, 0 );
  452.  
  453. I agree that I don't see any documentation on _Delay in NIM OSUtils / TBE /
  454. MoreTB and so on. On the other hand I see the _Delay trap being used
  455. in several code examples shown in the NIM volumes! It looks like
  456. an oversight by the NIM editors? The MTBA simply reflects what's
  457. written and what's not in the current NIM, it appears to me
  458.  
  459. Regarding the definition of Delay, OSUtils.h reads
  460.  
  461. extern pascal void Delay(long numTicks, long *finalTicks)
  462.  TWOWORDINLINE(0xA03B, 0x2280);
  463.  
  464. I don't know other dev systems, but with CodeWarrior C/PPC if one uses
  465. the default precompiled header, ConditionalMacros.h is included. Now,
  466. ConditionalMacros.h says if GENERATINGPOWERPC, then that means CFMSYSTEMCALLS,
  467. and in that case TWOWORDINLINE means 'nothing'. So, in that case the linker
  468. looks for the symbol Delay in whatever library included in the project.
  469. For CW, Delay is defined in InterfaceLib, so as long as this lib is included,
  470. the software links and runs fine.
  471.  
  472. --
  473. Nobu Toge
  474.      Internet: ntoge@netcom.com     AppleLink:      n.toge
  475.      AOL     : ntoge                CompuServe:     76334,650           
  476. #include <StandardDisclaimers.h>
  477.  
  478. +++++++++++++++++++++++++++
  479.  
  480. >From joelaff@aol.com (JoeLaff)
  481. Date: 5 Apr 1995 23:16:48 -0400
  482. Organization: America Online, Inc. (1-800-827-6364)
  483.  
  484.  
  485. In article <3lt5gv$cdi@newsbf02.news.aol.com>, joelaff@aol.com (JoeLaff)
  486. wrote:
  487.  
  488. >loop that uses some multiple of TimeDBRA. This global variable is
  489. supposed
  490. >to provide some indication of computer speed (although the latest IM I
  491.  
  492. TechNote "PT 39 The DR Emulator" cautions against relying on DBRA for
  493. timing.
  494.  
  495. -- 
  496. Larry Rosenstein
  497. Taligent, Inc.
  498. <<<
  499.  
  500.  
  501. I looked this up in NIM OS Utilities:
  502. - ---
  503. "The TimeDBRA value is calculated in ROM and is affected by the processing
  504. method of the CPU (what's THAT mean?). Accordingly, for routines running
  505. in RAM, it is not necessarily a good measure of how fast the computer is."
  506. - ---
  507.  
  508. So this is not so great to use....
  509.  
  510. What would anyone suggest using to slow down say a CopyBits opperation to
  511. time an animation so that it runs at the same speed on all machines? 
  512.  
  513. (I can't use Ticks because a tick is too long.)
  514.  
  515. Thanks,
  516. Joe <----
  517. ****  E N D    O F    L I N E  ****
  518.  
  519. +++++++++++++++++++++++++++
  520.  
  521. >From learntv@aol.com (LearnTV)
  522. Date: 6 Apr 1995 13:10:30 -0400
  523. Organization: America Online, Inc. (1-800-827-6364)
  524.  
  525. >What would anyone suggest using to slow down say a CopyBits opperation to
  526. >time an animation so that it runs at the same speed on all machines? 
  527. >
  528. >(I can't use Ticks because a tick is too long.)
  529.  
  530. Check out the Time Manager.  Microseconds and Milliseconds.
  531.  
  532. Greg Bolsinga
  533. Learn Television
  534.  
  535. +++++++++++++++++++++++++++
  536.  
  537. >From grobbins@znet.com (Grobbins)
  538. Date: Sun, 09 Apr 1995 13:11:28 -0700
  539. Organization: Skunkworks
  540.  
  541. In article <dlakelan.797110197@isua1.iastate.edu>, dlakelan@iastate.edu
  542. (Dan Lakeland) wrote:
  543. >I don't know the granularity of Delay, but how about
  544. >while(TickCount() - prevTicks < TicksToWait)
  545. >        ;
  546.  
  547. In spite of the Inside Mac documentation lapse, calling Delay is
  548. preferable to looping on TickCount.  Delay tells the system that the
  549. current process doesn't need time right now; this potentially allows the
  550. OS to use the free cycles for something else.  Today, the distinction is
  551. academic since the Mac doesn't do anything during Delay calls, but in the
  552. future this may change.
  553.  
  554. Grobbins                               grobbins@znet.com
  555.  
  556. +++++++++++++++++++++++++++
  557.  
  558. >From jumplong@aol.com (Jump Long)
  559. Date: 16 Apr 1995 23:17:30 -0400
  560. Organization: America Online, Inc. (1-800-827-6364)
  561.  
  562. >In article <dlakelan.797110197@isua1.iastate.edu>, dlakelan@iastate.edu
  563. >(Dan Lakeland) wrote:
  564. >>I don't know the granularity of Delay, but how about
  565. >>while(TickCount() - prevTicks < TicksToWait)
  566. >>        ;
  567. >
  568. >In spite of the Inside Mac documentation lapse, calling Delay is
  569. >preferable to looping on TickCount.  Delay tells the system that the
  570. >current process doesn't need time right now; this potentially allows the
  571. >OS to use the free cycles for something else.  Today, the distinction is
  572. >academic since the Mac doesn't do anything during Delay calls, but in the
  573. >future this may change.
  574.  
  575. Another thing to note about Delay... don't call it at interrupt time. The
  576. first thing it does is fully enable interrupts which probably wouldn't be
  577. a good thing to do at interrupt time.
  578.  
  579. - Jim
  580.  
  581. +++++++++++++++++++++++++++
  582.  
  583. >From altura@aol.com (ALTURA)
  584. Date: 17 Apr 1995 15:20:49 -0400
  585. Organization: America Online, Inc. (1-800-827-6364)
  586.  
  587. > Is Delay() defunct?
  588.  
  589. DeNo
  590.  
  591. ---------------------------
  592.  
  593. >From reed@medicine.wustl.edu (Thomas Reed)
  594. Subject: Looking for advice on a jGNEFilter...
  595. Date: Tue, 11 Apr 1995 12:08:56 -0500
  596. Organization: Washington University
  597.  
  598. I'm getting ready to try my hand at implementing a jGNEFilter, but I've
  599. got some technical questions.  This filter will be for an application, not
  600. an extension, so there are some problems I can see that I haven't found a
  601. really elegant answer to yet.  Hopefully, someone out there can give me
  602. some advice.
  603.  
  604. The problem is that the filter has to be able to compensate for the fact
  605. that the application might quit, or even worse, crash.  In which case, if
  606. the filter didn't compensate, it would hose everything when it tried to
  607. call a function in the app.
  608.  
  609. Now, there are several solutions I can see, but I'm not satisfied with any
  610. of them.  First, I could have the filter not call any functions in my app,
  611. and communicate with the app by using AppleEvents.  But, it seems like
  612. this could flood the machine in AppleEvents, since I'd be potentially
  613. interested in seeing the data for each keystroke.
  614.  
  615. Second, I thought about having the filter installed from an INIT, so it
  616. would always be there.  But, the problem arises of how it can tell that my
  617. app is running, how my app finds the filter to change the filter's stored
  618. data (stuff like the app's A5, handler in the app to call, etc.), how the
  619. filter figures out that the app has quit or crashed, etc.
  620.  
  621. I considered having the app install a filter that checks the process list
  622. before calling a handler in my app.  This would solve the problems with
  623. the filter not hosing when the app quits or crashes (quitting actually
  624. wouldn't be a problem, as I could just change some value in the filter
  625. before quitting).
  626.  
  627. This still leaves a question open, though.  Do I install the filter from
  628. the app just once, and somehow (maybe via an AppleEvent) get the address
  629. of the filter back on the second launch.  But, that's flawed, because
  630. there's not a way to determine when the app starts up that the filter is
  631. installed.  So I considered having the filter disable itself when the app
  632. isn't running, and having the app install a second filter on the next
  633. launch.  But, seems like this could fill up the System heap.
  634.  
  635. I don't know what to do!  Please help!  (Sorry for the length...)
  636.  
  637. -Thomas
  638.  
  639. =====================================================
  640. Thomas Reed                     Washington University
  641. reed@visar.wustl.edu               Medical School
  642. reed@medicine.wustl.edu            Saint Louis, MO
  643. - ---------------------------------------------------
  644. Clothes make the man.  Naked people have little or no
  645. influence on society.  -- Mark Twain
  646. =====================================================
  647.  
  648. Opinions posted are not the opinions of Wash. U.
  649.  
  650. +++++++++++++++++++++++++++
  651.  
  652. >From Eric Bowman <bobo@earthlink.net>
  653. Date: 14 Apr 1995 01:20:00 GMT
  654. Organization: Esoterotica Research
  655.  
  656. In article <reed-1104951208560001@thomas_mac.wustl.edu> Thomas Reed,
  657. reed@medicine.wustl.edu writes:
  658. >I'm getting ready to try my hand at implementing a jGNEFilter, but I've
  659. >got some technical questions.  This filter will be for an application, not
  660. >an extension, so there are some problems I can see that I haven't found a
  661. >really elegant answer to yet.  Hopefully, someone out there can give me
  662. >some advice.
  663. >The problem is that the filter has to be able to compensate for the fact
  664. >that the application might quit, or even worse, crash.  In which case, if
  665. >the filter didn't compensate, it would hose everything when it tried to
  666. >call a function in the app.
  667.  
  668. I'm preparing to release a Component Manager component called "GNE
  669. Manager"
  670. which handles much of the gnarliness of installing filters.  The component
  671. is registered at startup, and patches jGNEFilter at that time.
  672.  
  673. Client applications open an instance of the component, and pass it a
  674. UPP to their filter function.  The component takes care of setting up
  675. A5 and restores whatever zone was the current zone when the component was
  676. opened. If your app shuts down unexpectedly, the Component Manager 
  677. closes any component instances that lived in your app's heap, which 
  678. prevents calls to never-never land.  At least in principle; I haven't
  679. tested this too thoroughly yet.
  680.  
  681. It's super cool and makes patching jGNEFilter a breeze,, but I think it's 
  682. still buggy, and it's not documented at all, so I was going to work on 
  683. it a bit more before releasing it.  It borrows heavily from Pete
  684. Resnick's 
  685. "jGNE Helper" code that's floating around.  At least, I *think* Pete
  686. wrote 
  687. it, I'm sure he'll tell me if I'm wrong.
  688.  
  689. If you want to help me debug it, I'll gladly send it to you now.
  690.  
  691. Now that I'm unemployed, I have lots of time on my hands. :)
  692.  
  693. cheers,
  694. bobo
  695. --
  696. bobo@earthlink.net
  697. bobo@reed.edu
  698. Esoterotica Research
  699. If we do not expect the unexpected, we will never find it. - Heraclitus
  700.  
  701. +++++++++++++++++++++++++++
  702.  
  703. >From gurgle@dnai.com (Pete Gontier)
  704. Date: Wed, 19 Apr 1995 17:11:33 -0700
  705. Organization: cellular
  706.  
  707. In article <3mkik0$14e@mars.earthlink.net>,
  708. Eric Bowman <bobo@earthlink.net> wrote:
  709.  
  710. > (My jGNEFilter API component) borrows heavily from Pete Resnick's 
  711. > "jGNE Helper" code that's floating around.  At least, I *think* Pete
  712. > wrote it, I'm sure he'll tell me if I'm wrong.
  713.  
  714. Wrong Pete, but I forgive you. :-)
  715.  
  716. ______________________________________________________________________________
  717.  Pete Gontier -- MacZealotry, Ink. -- gurgle@dnai.com
  718.  
  719.  "It's great to work for a company that lets you build good software 
  720.   and doesn't give you any shit..."
  721.              -- John McEnerney, Metrowerks PowerPC Product Architect
  722.  
  723. ---------------------------
  724.  
  725. >From demos@amug.org (Demos)
  726. Subject: NEW DEVELOPMENT ARCHIVE at AMUG!
  727. Date: Sun, 16 Apr 1995 04:22:29 -0600
  728. Organization: University of Utah
  729.  
  730. Hi everyone,
  731. I am glad to announce that 4/16/95 Arizona Macintosh User Group is
  732. supporting development section! I volunteered to maintain the archive. I
  733. managed to mirror alt.sources.mac and other places I knew. The structure
  734. is pretty simple so far:
  735.  
  736. ftp.amug.org /pub/demos/development (hopefully we will move to /pub/development)
  737. the pub/demos/development directory contains:
  738. incoming/         (where you can upload new code examples)
  739. alt.sources.mac/  (mirror of alt.sources.mac)
  740. personal/         (code I have written)
  741. requests/         (you can request some code here if you want)
  742. and I can add another sections if you request.
  743. I belive AMUG will soon become a major macintosh development supporter, as
  744. well as the major macintosh contributer to the macintosh community.
  745.  
  746. If everything goes well, AMUG will press a CD with freely distributed
  747. source code. 
  748.  
  749. I personally wish to contribute all the code I have written that can be
  750. distributed. My personal interests involve real time animation and 3d
  751. graphics as well as communications; I am interested in writing more
  752. DEMO(s) for Macintosh. 
  753.  
  754. Please let me know if you like that idea and if you own a little
  755. collection of the sample codes, I am willing to mirror your site.
  756.  
  757. Thank you!
  758.  
  759. Regards,
  760. Demos.
  761.  
  762. _____________________________________________________________________
  763. Demos <demos@amug.org>   |  IRC: #macdev  |  ftp://amug.org/pub/demos
  764.  
  765. ---------------------------
  766.  
  767. >From gt0800c@prism.gatech.edu (Olivier Baur)
  768. Subject: Problem drawing PICT with QT (-8976!?)
  769. Date: 14 Apr 1995 18:25:31 GMT
  770. Organization: Georgia Institute of Technology
  771.  
  772. Hi there !
  773.  
  774. I've got a strange problem when I try drawing a PICT file containing a
  775. JPEG compressed pixmap (PICT opcode $8200) into a G-World, using the QT
  776. function DrawPictureFile: 
  777. QuickTime will return an error code -8976 if the GWorld is smaller than
  778. the destination rectangle I'm trying to draw to (I'm drawing the pict
  779. file band by band, because it can be huge -- 10Mb+ -- and the routine
  780. should be able to run with only little memory avaible).
  781.  
  782. Now, the big problem is that error -8976 is NOT referenced in
  783. IM-QuickTime (I've found that error -8976 is related to some printing
  784. problem!)...
  785. What's more, most of the time, DrawPictureFile will actually draw the
  786. pict into the gworld AND return that error code. I've tried ignoring
  787. error -8976, but the problem is that it happens only "most of the
  788. time", and sometimes DrawPictureFile won't do nothing (especially for
  789. the last bands of the pict).
  790.  
  791. HELP !!!
  792. Any help will be welcome !!!
  793.  
  794. Olivier Baur
  795.  
  796. +++++++++++++++++++++++++++
  797.  
  798. >From sandvik@apple.com (Kent Sandvik)
  799. Date: Sat, 15 Apr 1995 16:26:19 -0800
  800. Organization: Apple Computer, Inc. Developer Technical Support
  801.  
  802. In article <3mmemr$3id@mordred.gatech.edu>, gt0800c@prism.gatech.edu
  803. (Olivier Baur) wrote:
  804. > Now, the big problem is that error -8976 is NOT referenced in
  805. > IM-QuickTime (I've found that error -8976 is related to some printing
  806. > problem!)...
  807. > What's more, most of the time, DrawPictureFile will actually draw the
  808. > pict into the gworld AND return that error code. I've tried ignoring
  809. > error -8976, but the problem is that it happens only "most of the
  810. > time", and sometimes DrawPictureFile won't do nothing (especially for
  811. > the last bands of the pict).
  812.  
  813. Try to install the Apple MM Tuner 2.0.1 to see what happens! Yes, just
  814. ignore that error for the time being.
  815.  
  816. --Kent
  817.  
  818. -- 
  819. Kent Sandvik   sandvik@apple.com                  Working with Multimedia stuff...
  820. Apple Developer Technical Support.                                     Private activities on Internet.
  821.  
  822. ---------------------------
  823.  
  824. >From buddy@cs.tu-berlin.de (Rolf-Stephan Badura)
  825. Subject: QuickTime & MPEG-Streams?
  826. Date: Tue, 11 Apr 1995 08:19:24 +0200
  827. Organization: Technical University of Berlin, Germany
  828.  
  829. Hi,
  830.  
  831. I must implement a window with a MPEG stream from the net. Hardware
  832. (Mason) is in my box. I like to use QuickTime, maybe with a special Media
  833. Data Handler. But how can I tell QuickTime to use this MPEG data (I should
  834. not copy the data to the local machine!).
  835.  
  836. Thanx, BuddY+E
  837.  
  838. <URL:http://www.cs.tu-berlin.de/~buddy>
  839.  
  840. +++++++++++++++++++++++++++
  841.  
  842. >From sandvik@apple.com (Kent Sandvik)
  843. Date: Thu, 13 Apr 1995 22:09:09 -0800
  844. Organization: Apple Computer, Inc. Developer Technical Support
  845.  
  846. In article <buddy-1104950819240001@async105.zrz.tu-berlin.de>,
  847. buddy@cs.tu-berlin.de (Rolf-Stephan Badura) wrote:
  848.  
  849. > Hi,
  850. > I must implement a window with a MPEG stream from the net. Hardware
  851. > (Mason) is in my box. I like to use QuickTime, maybe with a special Media
  852. > Data Handler. But how can I tell QuickTime to use this MPEG data (I should
  853. > not copy the data to the local machine!).
  854.  
  855. Phew, this is a long story. To tell it all shortly, check out the QT
  856. Conferencing APIs when they will ship some time this spring. QTC has a new
  857. architecture for streamed data, MPEG and such, and you should write so
  858. called stream players to handle the MPEG streams. Either you will write a
  859. specific system stream player that does it all, or separate audio and/or
  860. video stream players for decoding these parts.
  861.  
  862. Writing a data handler for MPEG is not recommended, this because the QT
  863. architecture is not really designed for this purpose. In other words
  864. whatever movie toolbox support we add it will be included as part of the
  865. stream player architecture, first in QTC, and then later in QT 2.x
  866. versions.
  867.  
  868. Now some of you wonder how we handle MPEG today, we read the data in from
  869. the file using our HFS data handler, have a specific MPEG media handler,
  870. and this one redirects the decoding stream to hardware. This is now the
  871. Wired box works just now (Mason). But if you want to read data over the
  872. network (video servers and such), you need to implement a specific data
  873. handler that will push the data up to the MPEG media handler that takes
  874. care of the rest.
  875.  
  876. --Kent
  877.  
  878. -- 
  879. Kent Sandvik   sandvik@apple.com                  Working with Multimedia stuff...
  880. Apple Developer Technical Support.                                     Private activities on Internet.
  881.  
  882. ---------------------------
  883.  
  884. >From aberno@genome.stanford.edu (Anthony Berno)
  885. Subject: Speeding up NewPtr
  886. Date: 29 Mar 1995 19:13:14 GMT
  887. Organization: Stanford DNA Sequence and Technology Center
  888.  
  889.  
  890. My app (both 68K and PPC) is spending a lot of time creating many
  891. (thousands) of small (~500 byte) chunks of memory using NewPtr.
  892. Unfortunately, this is taking a fair bit of time. Is there any way to
  893. speed up NewPtr for this type of memory usage, short of writing my own
  894. memory manager? Thanks.
  895.  
  896. -Anthony
  897.  
  898. +++++++++++++++++++++++++++
  899.  
  900. >From "Andrew C. Plotkin" <erkyrath+@CMU.EDU>
  901. Date: Wed, 29 Mar 1995 17:17:11 -0500
  902. Organization: Information Technology Center, Carnegie Mellon, Pittsburgh, PA
  903.  
  904. Excerpts from netnews.comp.sys.mac.programmer.misc: 29-Mar-95 Speeding
  905. up NewPtr Anthony Berno@genome.sta (306)
  906.  
  907. > My app (both 68K and PPC) is spending a lot of time creating many
  908. > (thousands) of small (~500 byte) chunks of memory using NewPtr.
  909. > Unfortunately, this is taking a fair bit of time. Is there any way to
  910. > speed up NewPtr for this type of memory usage, short of writing my own
  911. > memory manager? 
  912.  
  913. No. 
  914.  
  915. Fortunately, writing your own memory manager is pretty easy, especially
  916. if all the chunks are the same size. NewPtr a big chunk (the size of 200
  917. small chunks, say) and divvy it up according to some clever scheme. The
  918. details depend on whether you want to be able to dispose them as
  919. quickly, or at all.
  920.  
  921. --Z
  922.  
  923. "And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
  924.  
  925. +++++++++++++++++++++++++++
  926.  
  927. >From Nathaniel P Woods <nw2d+@andrew.cmu.edu>
  928. Date: Wed, 29 Mar 1995 19:59:59 -0500
  929. Organization: Freshman, Electrical and Computer Engineering, Carnegie Mellon, Pittsburgh, PA
  930.  
  931. >My app (both 68K and PPC) is spending a lot of time creating many
  932. >(thousands) of small (~500 byte) chunks of memory using NewPtr.
  933. >Unfortunately, this is taking a fair bit of time. Is there any way to
  934. >speed up NewPtr for this type of memory usage, short of writing my own
  935. >memory manager? Thanks.
  936.  
  937. My advice to you would be to make your own memory management that
  938. allocates large blocks with NewPtr() and then parcels off chunks of
  939. these blocks off.
  940.  
  941. Nathaniel
  942.  
  943. +++++++++++++++++++++++++++
  944.  
  945. >From jens_alfke@powertalk.apple.com (Jens Alfke)
  946. Date: Fri, 31 Mar 1995 18:25:52 GMT
  947. Organization: Apple Computer, Inc.
  948.  
  949. In article <gjSU_Du00iWTMBxoN3@andrew.cmu.edu>, Nathaniel P Woods
  950. <nw2d+@andrew.cmu.edu> wrote:
  951.  
  952. > My advice to you would be to make your own memory management that
  953. > allocates large blocks with NewPtr() and then parcels off chunks of
  954. > these blocks off.
  955.  
  956. ...which is exactly what the malloc and operator new libraries supplied
  957. with C and C++ compilers do. They're typically much faster than NewPtr.
  958.  
  959.  
  960. Jens Alfke_________OpenDoc Geometer_________jens_alfke@powertalk.apple.com
  961.                                            OpenDoc info: FTP to CILabs.org
  962.  
  963.          Visit Scenic Flood Control Dam No. 3.      
  964.  
  965. +++++++++++++++++++++++++++
  966.  
  967. >From ctd13@uow.edu.au (Magao)
  968. Date: 4 Apr 1995 15:40:48 +1000
  969. Organization: University of Wollongong, NSW, Australia.
  970.  
  971. In <aberno-2903951115190001@b403-pmac.stanford.edu> aberno@genome.stanford.edu (Anthony Berno) writes:
  972.  
  973.  
  974. >My app (both 68K and PPC) is spending a lot of time creating many
  975. >(thousands) of small (~500 byte) chunks of memory using NewPtr.
  976. >Unfortunately, this is taking a fair bit of time. Is there any way to
  977. >speed up NewPtr for this type of memory usage, short of writing my own
  978. >memory manager? Thanks.
  979.  
  980.    Well, you can do it by *kinda* writing your own memory manager ... it's
  981. especially easy if all your chunks are the same size (which is what I'm
  982. going to do here).
  983.  
  984.    Allocate one *big* chunk of memory (preferably large enough to hold
  985. them maximum number of items, otherwise you'll have to allocate another
  986. chunk later and it starts getting messy).
  987.  
  988.    Keep track of the address of the *next* chunk to be used (i.e. the
  989. address of the last chunk + the chunk size (in bytes)). When you first
  990. allocate the big chunk you will of course set the next address to the
  991. start of the chunk.
  992.  
  993.    Whenever you need a new chunk simply assign the address of the next chunk
  994. to the pointer and increment the next chunk pointer the correct number of
  995. bytes.
  996.  
  997.    Note : This model assumes that
  998.                 all chunks are the same size
  999.                 enough memory is preallocated to hold all chunks
  1000.                 you either never want to free memory (except when you've
  1001.                 finished with the whole lot) OR
  1002.                 you don't care that freed memory will be unusable.
  1003.  
  1004.    If you want any other bells and whistles then things can start to get
  1005. a bit messy (you've got to actually make some design decisions). One of
  1006. these design decisions should be "Should I implement this myself, or
  1007. should I go with malloc/free which is already doing this ?" (I don't
  1008. *know* of any implementation of malloc/free which doesn't preallocate
  1009. a big chunk of memory - but there may be some out there). Of course,
  1010. this is assuming you're using C - if you're using Pascal I don't know
  1011. how new/dispose (or new/delete for C++) are handled. I guess you're using
  1012. Codewarrior (oops ... I've completely forgotten which newsgroup I'm in ...)
  1013. so you could ask Metrowerks what method they use.
  1014.  
  1015.  
  1016.                                        _/_/_/_/
  1017.    __|  __|        _/_|     _/_/_/      _/_|     _/_/_/
  1018.   _/_| _/_|      _/  _|   _/          _/  _|   _/    _/
  1019.  -/ _|_/ _|    _/_/_/_|  _/ _/_/_/  _/_/_/_|  _/    _/
  1020. _/  __/  _|  _/      _|  _/_/_/   _/      _|  _/_/_/
  1021.  
  1022.    Tim Delaney (TCD Software)     ctd13@uow.edu.au
  1023.  
  1024. +++++++++++++++++++++++++++
  1025.  
  1026. >From mantei@neuro.biol.ethz.ch (Ned Mantei)
  1027. Date: Tue, 04 Apr 1995 15:35:42 +0200
  1028. Organization: Swiss Federal Institute of Technology (ETHZ)
  1029.  
  1030. In article <aberno-2903951115190001@b403-pmac.stanford.edu>,
  1031. aberno@genome.stanford.edu (Anthony Berno) wrote:
  1032.  
  1033. > My app (both 68K and PPC) is spending a lot of time creating many
  1034. > (thousands) of small (~500 byte) chunks of memory using NewPtr.
  1035. > Unfortunately, this is taking a fair bit of time. Is there any way to
  1036. > speed up NewPtr for this type of memory usage, short of writing my own
  1037. > memory manager? Thanks.
  1038.  
  1039. Perhaps use malloc() from the ANSI library? This asks the system for
  1040. memory in larger chunks and hands it out to you. NewPtr is only called if
  1041. you use up a large chunk. I seem to remember that this should be faster
  1042. for a case like yours.
  1043.  
  1044. -- 
  1045. Ned Mantei
  1046. Neurobiology, Swiss Federal Institute of Technology
  1047. CH-8093 Zurich, Switzerland
  1048. mantei@neuro.biol.ethz.ch
  1049.  
  1050. +++++++++++++++++++++++++++
  1051.  
  1052. >From jhs@interlog.com (Henri Schueler)
  1053. Date: Tue, 04 Apr 1995 11:51:22 -0500
  1054. Organization: H&h Software
  1055.  
  1056. In <aberno-2903951115190001@b403-pmac.stanford.edu>
  1057. aberno@genome.stanford.edu (Anthony Berno) writes:
  1058.  
  1059.  
  1060. >My app (both 68K and PPC) is spending a lot of time creating many
  1061. >(thousands) of small (~500 byte) chunks of memory using NewPtr.
  1062. >Unfortunately, this is taking a fair bit of time. Is there any way to
  1063. >speed up NewPtr for this type of memory usage, short of writing my own
  1064. >memory manager? Thanks.
  1065.  
  1066. Remember that NewPtr causes memory compaction. It does this because it
  1067. wants to avoid problems that are caused by fragmentation from Ptrs.
  1068.  
  1069. When I first started programming on the Mac, I assumed that HLocked
  1070. Handles would be more expensive than Ptrs, so when either would do, I used
  1071. Ptrs. This was a mistake. Its much better to do:
  1072.     a = NewHandle (b);
  1073.     HLock(a);
  1074.     c = *a;
  1075. ..do some work using c, for a short term
  1076.     DisposeHandle(a);
  1077.  
  1078. than to use NewPtr/DisposePtr.
  1079.  
  1080. - -------------------------------------------------------------------
  1081. J.Henri Schueler              H&h Software             1-416-698-9075
  1082. jhs@interlog.com (preferred)    (alternate) J.Henri_Schueler@magic.ca
  1083.  
  1084. +++++++++++++++++++++++++++
  1085.  
  1086. >From gspnx@di.unito.it (Fabrizio Oddone)
  1087. Date: Mon, 10 Apr 1995 12:59:44 +0200
  1088. Organization: Computer Science Faculty, Torino
  1089. In article <radix-0604950053340001@net48.efn.org>, radix@efn.org (Gregory
  1090. Jorgensen) wrote:
  1091.  
  1092. > Use the standard library functions malloc() and free(), which do exactly
  1093. > what you want. With Symantec C malloc's crossover size (the size of the
  1094. > largest block it will allocate in its own pools before it goes to NewPtr)
  1095. > is 15,000 bytes. In Code Warrior the crossover is 32K. You can change this
  1096. > magic number and recompile the Symantec libraries.
  1097. > Don't reinvent the wheel--it's been done.
  1098.  
  1099. In theory...
  1100.  
  1101. It just happens that for REAL usage, both Symantec and CodeWarrior (4.5,
  1102. never tried the newer ones) are broken.
  1103.  
  1104. When optimizing GW/Ada Mac, I had to rewrite malloc/free/realloc from
  1105. scratch in order to let them work.
  1106.  
  1107. Nice side effects:
  1108. I can choose the crossover size;
  1109. I can use temporary memory by simply changing a #define.
  1110.  
  1111. It seems that the _NewPtr inefficiency is an FAQ...
  1112.  
  1113. Anybody wants the source?
  1114.  
  1115. -- 
  1116.  Fabrizio Oddone <gspnx@di.unito.it>
  1117. http://www.di.unito.it/pub/WWW/www_student/apple/FabrizioOddone/
  1118.  
  1119. +++++++++++++++++++++++++++
  1120.  
  1121. >From g_austin@devtools.symantec.com (Glenn L. Austin)
  1122. Date: Wed, 12 Apr 1995 11:50:11 -0700
  1123. Organization: Symantec Corporation
  1124.  
  1125. In article <gspnx-1004951259440001@macstud1.di.unito.it>,
  1126. gspnx@di.unito.it (Fabrizio Oddone) wrote:
  1127.  
  1128.  
  1129. > In article <radix-0604950053340001@net48.efn.org>, radix@efn.org (Gregory
  1130. > Jorgensen) wrote:
  1131. > > Use the standard library functions malloc() and free(), which do exactly
  1132. > > what you want. With Symantec C malloc's crossover size (the size of the
  1133. > > largest block it will allocate in its own pools before it goes to NewPtr)
  1134. > > is 15,000 bytes. In Code Warrior the crossover is 32K. You can change this
  1135. > > magic number and recompile the Symantec libraries.
  1136. > > Don't reinvent the wheel--it's been done.
  1137. > In theory...
  1138. > It just happens that for REAL usage, both Symantec and CodeWarrior (4.5,
  1139. > never tried the newer ones) are broken.
  1140. > When optimizing GW/Ada Mac, I had to rewrite malloc/free/realloc from
  1141. > scratch in order to let them work.
  1142. > Nice side effects:
  1143. > I can choose the crossover size;
  1144. > I can use temporary memory by simply changing a #define.
  1145.  
  1146.  
  1147. At Symantec, we've already rewritten malloc/free/realloc to better deal
  1148. with memory on the Macintosh.  The new version does more checking (which
  1149. you can turn off) and is configurable from code (by changing global
  1150. variables).  However, since we didn't get as much time to check it as we
  1151. wanted, the old one is the default one shipped with 8.0, although the
  1152. alternate malloc is in the Goodies folder.
  1153.  
  1154. //
  1155. // Glenn L. Austin, Symantec Macintosh Developer Tools Support
  1156. // mailto:g_austin@devtools.symantec.com
  1157. //
  1158.  
  1159. +++++++++++++++++++++++++++
  1160.  
  1161. >From jens_alfke@powertalk.apple.com (Jens Alfke)
  1162. Date: Thu, 13 Apr 1995 15:05:19 GMT
  1163. Organization: Apple Computer, Inc.
  1164.  
  1165. OpenDoc has its own memory manager that is optimized for nonrelocatable
  1166. malloc-style allocation. It's based on the memory manager written for
  1167. MacApp 3.1 and Bedrock. The memory manager is built as a separate shared
  1168. library called (duh) "Memory Manager". It's in the same folder as all the
  1169. other OpenDoc libraries (in the Extensions folder.) There's full
  1170. documentation of its API in the Technical Notes folder on the CD.
  1171. This library has no dependencies on the rest of OpenDoc. You can use it
  1172. from your own app and the rest of OpenDoc will not load. The memory
  1173. manager is only about 16k in size (about 30k in the debug build.)
  1174. It's got a lot of nice debugging features too, including heap checking.
  1175. Drawbacks: On 68k it requires the use of CFM, i.e. it can only be called
  1176. from new-runtime apps. There are no plans to ship it separately from the
  1177. rest of OpenDoc, and you probably can't redistribute it yourself.
  1178. Otherwise, have fun with it...
  1179.  
  1180.  
  1181. Jens Alfke_________OpenDoc Geometer_________jens_alfke@powertalk.apple.com
  1182.                                            OpenDoc info: FTP to CILabs.org
  1183.  
  1184.          Visit Scenic Flood Control Dam No. 3.      
  1185.  
  1186. ---------------------------
  1187.  
  1188. >From rmckay@gloin.carleton.ca (Reevan McKay)
  1189. Subject: Where is the QTv2.0 header file?
  1190. Date: Sun, 9 Apr 1995 21:46:50 GMT
  1191. Organization: Carleton University
  1192.  
  1193.  
  1194.  
  1195. Does anyone have any idea where we are supposed to get header files for
  1196. Quicktime 2.0?  Can we get them from info.apple.com?  Or do we need to buy
  1197. a new compiler? >:(  Failing that, does anyone have a QTv2.0 header file
  1198. that they can send me (THINK C++ v7.04)?  If that's legal, of course...
  1199. I especially need the QT Musical Architecture stuff.  Any help would be
  1200. real handy. :)
  1201.  
  1202. Send email to rmckay@chat.carleton.ca
  1203.  
  1204. Thanx.
  1205.  
  1206. +++++++++++++++++++++++++++
  1207.  
  1208. >From sandvik@apple.com (Kent Sandvik)
  1209. Date: Sun, 09 Apr 1995 22:01:08 -0800
  1210. Organization: Apple Computer, Inc. Developer Technical Support
  1211.  
  1212. In article <D6sF62.4tG@cunews.carleton.ca>, rmckay@gloin.carleton.ca
  1213. (Reevan McKay) wrote:
  1214.  
  1215. > Does anyone have any idea where we are supposed to get header files for
  1216. > Quicktime 2.0?  Can we get them from info.apple.com?  Or do we need to buy
  1217. > a new compiler? >:(  Failing that, does anyone have a QTv2.0 header file
  1218. > that they can send me (THINK C++ v7.04)?  If that's legal, of course...
  1219. > I especially need the QT Musical Architecture stuff.  Any help would be
  1220. > real handy. :)
  1221.  
  1222. The QT header files are part of the Universal header files, 2.0a3 is the
  1223. latest version, even if the MW 5.5 upgrade had a couple of newer header
  1224. files. Available from:
  1225. ETO CDs
  1226. Symantec releases
  1227. MW releases
  1228. PowerPC tool releases
  1229. QT 2.0 SDK CD (worth getting as it's the reference CD for all the material
  1230. related to QT programming today)
  1231. OS SDK CDs (worth getting as these are the complete sets of APIs and
  1232. libraries for Mac application development)
  1233. ftp.info.apple.com, url:
  1234. ftp://ftp.info.apple.com/Apple.Support.Area/Developer_Services/Tool_Chest/Interfaces/Universal_Interfaces/
  1235. (found that one after five minutes  of browsing)
  1236.  
  1237. Cheers, Kent
  1238. PS: I tested about 80% of the QT SDK CD samples using 2.0a3.
  1239.  
  1240. -- 
  1241. Kent Sandvik   sandvik@apple.com                  Working with Multimedia stuff...
  1242. Apple Developer Technical Support.                                     Private activities on Internet.
  1243.  
  1244. +++++++++++++++++++++++++++
  1245.  
  1246. >From sandvik@apple.com (Kent Sandvik)
  1247. Date: Mon, 17 Apr 1995 23:31:36 -0800
  1248. Organization: Apple Computer, Inc. Developer Technical Support
  1249.  
  1250. In article <D6sF62.4tG@cunews.carleton.ca>, rmckay@gloin.carleton.ca
  1251. (Reevan McKay) wrote:
  1252.  
  1253. > Does anyone have any idea where we are supposed to get header files for
  1254. > Quicktime 2.0?  Can we get them from info.apple.com?  Or do we need to buy
  1255. > a new compiler? >:(  Failing that, does anyone have a QTv2.0 header file
  1256. > that they can send me (THINK C++ v7.04)?  If that's legal, of course...
  1257. > I especially need the QT Musical Architecture stuff.  Any help would be
  1258. > real handy. :)
  1259.  
  1260. Universal headers, URL:
  1261. ftp://ftp.info.apple.com/Apple.Support.Area/Developer_Services/Tool_Chest/Interfaces/Universal_Interfaces/
  1262.  
  1263. QuickTime 2.0 documentation, Acrobat Format:
  1264. ftp://ftp.info.apple.com/dts/quicktime/QT_MAC.PDF.hqx
  1265.  
  1266. This should go to the developer FAQ...
  1267.  
  1268. --Kent/DTS
  1269.  
  1270. -- 
  1271. Kent Sandvik   sandvik@apple.com                  Working with Multimedia stuff...
  1272. Apple Developer Technical Support.                                     Private activities on Internet.
  1273.  
  1274. ---------------------------
  1275.  
  1276. >From dlakelan@iastate.edu (Dan Lakeland)
  1277. Subject: [MINI FAQ] Programming with MacTCP
  1278. Date: 16 Apr 95 17:15:54 GMT
  1279. Organization: Iowa State University, Ames, Iowa
  1280.  
  1281. Some info on using TCP on the mac:
  1282.  
  1283. (note none of this is guaranteed to apply to OpenTransport)
  1284.  
  1285. FIRST: Use the Universal Headers. The file MacTCP.h includes all the
  1286. info in the older headers in ONE FILE. Get these from ftp.info.apple.com
  1287. if you don't have them (MW codewarrior comes with them).
  1288.  
  1289. SECOND: there is a bug in the Universal Headers (the version I have at
  1290. least) which doesn't set the struct alignment to 68k unless you're
  1291. compiling on a PPC. Therefore, you should either edit a copy of the
  1292. headers to do this, or DON'T USE 68k-4byte alignment in your project....
  1293.  
  1294. ALSO:
  1295. Watch out for MacTCP.p because it uses 'array of byte' where it
  1296. really really really wants to be 'packed array of byte'.
  1297.  
  1298. The MacTCP interfaces have a long long tradition of being screwed up :-)
  1299.  
  1300. THIRD: GET the MacTCP DK from ftp://seeding.apple.com. And
  1301. ftp://ftp.info.apple.com it describes how to use the TCP driver.
  1302.  
  1303. FOURTH: An overview of the TCP Driver:
  1304.  
  1305. I have been told that this section is less useful, as it contaings an
  1306. overview of information found in the TCPDK which is so quick that it
  1307. might confuse newbies, and so sparse that people who know driver
  1308. programming don't need to read it. But I think it's useful to get an
  1309. overview of the types of things you can do with the TCP driver. It is
  1310. NOT a replacement for the TCPDK which is available at
  1311. ftp://seeding.apple.com. And ftp://ftp.info.apple.com
  1312.  
  1313. Create a Stream with a PBControl call: This call allocates all the
  1314. information and control structures and buffers etc, and associates them
  1315. with a stream ID which is returned to you. You also may not touch the
  1316. internals of the stream (esp. the buffers you gave to TCP) until you
  1317. have released it.
  1318.  
  1319. WARNING: You absolutely must release any stream you successfully create. 
  1320. Failure to do this will cost death and destruction that you don't want to
  1321. be responsible for. In order to facilitate debugging. There is an init
  1322. Zap_TCP which is available at ftp.info.apple.com which releases streams
  1323. that are left over when your app crashes. Get it, but don't rely on it :-)
  1324.  
  1325. Find an Address (you can use the Domain Name Resolver to translate from
  1326. either a "name.name.name" type string or "number.number.number.number"
  1327. type string into 6 bytes which completely describe a location on the
  1328. internet. An ADDRESS: is 4 bytes. A port is 2 bytes (hence 6 bytes)
  1329.  
  1330. The DNR does not deal with ports.  The DNR will (sometimes, if you're
  1331. really nice to it :-) turn names in to 4 byte IP addresses.
  1332.  
  1333. ports do however come semi-magically from opening a stream. When you
  1334. attempt to connect to an address you specify a port. When you wait for
  1335. a connection you recieve the port that the other person attempted to
  1336. connect to.
  1337.  
  1338. WARNING: There is no way to abort a name lookup in progress - you must
  1339. wait til it completes or timesout.  Failure to do so will (you know the
  1340. rest... :-)
  1341.  
  1342. Which brings up a good point. Set your timeouts to be valid :-). They're
  1343. usually a byte which gives the number of seconds to wait until failure.
  1344.  
  1345. Open a Connection with a PBControl call:
  1346. Use the stream allocated above and the address and port found above...
  1347.  
  1348. Send Data via PBControl calls:
  1349. Pass a send data record, it is described in the DK, but it looks
  1350. approximately like:
  1351.  
  1352. short
  1353. Ptr
  1354. short
  1355. Ptr
  1356. ....
  1357. short
  1358. Ptr
  1359. short 0 // end of data is signified by 2 zero bytes
  1360.  
  1361. Each Ptr points to some data, and each short describes how long the data
  1362. is. The TCP Driver will send all the data (eventually)
  1363.  
  1364. Recieve Data via PBControl calls:
  1365. Either have TCP copy data into your buffer, or give you a pointer to
  1366. it's own internal buffer so you can read from it.... In the latter case
  1367. you must also tell TCP When you're done..
  1368.  
  1369. Close/Abort connection via PBControl:
  1370.  
  1371. WARNING: Don't call Close twice.
  1372. NOTE: There is generally no need to call abort, since releasing a stream
  1373. will abort the connection.
  1374. NOTE: Giving a close command does not close a stream.  All it means is
  1375. that you will not send any more data.  The stream remains open until both
  1376. sides have closed it.  Releasing a stream before it is closed gracefully
  1377. (some time after both parties have closed it) may result in data loss.
  1378.  
  1379. Also there are a variety of things that might cause a stream to abort
  1380. automatically, like for example timeouts. You can usually pass TCP a
  1381. function to call when something anomalous happens, if this function is
  1382. set correctly then you handle the anomaly yourself. Otherwise the stream
  1383. aborts, and returns some sort of error to you. So don't go sending data
  1384. across an aborted connection.
  1385.  
  1386. Deallocate stream when done (you guessed it PBControl):
  1387. When you do this, you get all that buffer memory back. You can reuse it,
  1388. or dispose of it, but you can't touch it until after you've disposed the
  1389. stream. 
  1390.  
  1391. Hope this has helped someone.
  1392.  
  1393. Many thanks to Peter Lewis, the TCP guru for suggestions and additions.
  1394.  
  1395. This FAQ is copyright 1995 by Daniel Lakeland. It is freely
  1396. distributable under the condition that any modifications be sent to me
  1397. for inclusion into the general FAQ. Suggestions for additional info
  1398. should be sent to me. dlakelan@iastate.edu. I do not guarantee the
  1399. accuracy of this information, nor do I make any guarantees of anything
  1400. (this is the cover my butt portion of the document).
  1401.  
  1402.  
  1403. -- 
  1404. Daniel Lakeland: Macintosh Hacker, Mathematics Major, NRA Member.
  1405. Macintosh Hacking, an art best learned w/ an axe...
  1406. The computer programmer's worst nightmare:
  1407. Unwittingly finding compiler bugs.
  1408.  
  1409. ---------------------------
  1410.  
  1411. >From mneylon@engin.umich.edu (Michael K. Neylon)
  1412. Subject: [Q] Temporary Files
  1413. Date: 12 Apr 1995 23:33:44 GMT
  1414. Organization: University of Michigan Engineering, Ann Arbor
  1415.  
  1416. My app will create a file with both a resource and a data fork, and I 
  1417. would like to keep the non saved version in a temporary file because
  1418. of the resource fork.  However, I don't see any info in the HIG or
  1419. IM:Files that mentions where temp files should be stored.  Where
  1420. are temporary files usually stored, and is there a good way to name
  1421. them.  Any info is appriciated.
  1422.  
  1423. -- 
  1424.   Michael K. Neylon, Graduate Student           | "It was a dark and stormy
  1425.   Dept. of ChE, Univ. of Michigan               |   night...I had just 
  1426.   mneylon@engin.umich.edu                       |   taken a creative 
  1427.   http://www.engin.umich.edu/labs/mel/mneylon/  |   writing course..." MST3K
  1428.  
  1429. +++++++++++++++++++++++++++
  1430.  
  1431. >From mclow@coyote.csusm.edu (Marshall Clow)
  1432. Date: Wed, 12 Apr 1995 22:45:11 -0700
  1433. Organization: Aladdin Systems
  1434.  
  1435. In article <3mho0o$cc7@srvr1.engin.umich.edu>, mneylon@engin.umich.edu
  1436. (Michael K. Neylon) wrote:
  1437.  
  1438. > My app will create a file with both a resource and a data fork, and I 
  1439. > would like to keep the non saved version in a temporary file because
  1440. > of the resource fork.  However, I don't see any info in the HIG or
  1441. > IM:Files that mentions where temp files should be stored.  Where
  1442. > are temporary files usually stored, and is there a good way to name
  1443. > them.  Any info is appriciated.
  1444.  
  1445.     Temporary files should be created in the "Temporary Items" folder on
  1446. the same volume as the data file, unless the data file is on a server
  1447. which you don't have write access to, in which case it should be created
  1448. in the "Temporary Items" folder on the boot volume. Whew!
  1449.  
  1450.     The "Temporary Items" folder can be found/created with FindFolder. See
  1451. the header file "Folders.h". Also NIM:Toolbox Essentials, pp 7-43 and
  1452. 7-54.
  1453.  
  1454. -- Marshall
  1455.  
  1456. -- 
  1457. Marshall Clow
  1458. Aladdin Systems
  1459. mclow@coyote.csusm.edu
  1460.  
  1461. +++++++++++++++++++++++++++
  1462.  
  1463. >From chuck@ocsmd.ocs.com (Chuck (Chuck Bo Buck...) McMath)
  1464. Date: Fri, 14 Apr 1995 14:23:59 GMT
  1465. Organization: Reed Technology and Information Services, Inc.
  1466.  
  1467. Michael K. Neylon (mneylon@engin.umich.edu) wrote:
  1468. : My app will create a file with both a resource and a data fork, and I 
  1469. : would like to keep the non saved version in a temporary file because
  1470. : of the resource fork.  However, I don't see any info in the HIG or
  1471. : IM:Files that mentions where temp files should be stored.  Where
  1472. : are temporary files usually stored, and is there a good way to name
  1473. : them.  Any info is appriciated.
  1474.         
  1475.    Well, if you can use FindFolder, there is a parameter for 'folderType'
  1476. called kTemporaryFolderType which identifies where you can store temp 
  1477. files.  Think Reference says it's on the root of the boot volume, in an
  1478. invisible folder (and I've used temp files, and agree with them!).
  1479.  
  1480. As to what to name them, my strategy was to derive a name based
  1481. upon the stuff I was storing on the disk.  That way, when I went to
  1482. create a temp file, I could look in the temp file folder and see if that
  1483. file had already been stuck there.  And if it had, I didn't have to
  1484. store it there again.  But it that approach doesn't apply, you could
  1485. call TickCount() or something like that, convert the number to a string
  1486. and use that.
  1487.  
  1488. Remember, temp files should only be around while your app is running,
  1489. so you should close and delete them when the app quits (or whenver you
  1490. are sure you're thru with the file).  And if you *really* wanna do it 
  1491. right, you'll check the temp directory when your app starts up to see 
  1492. if there is any garbage left over from a prior session in which your 
  1493. app blew up and didn't get a chance to clean up after itself (don't 
  1494. ask how I came up with that rule...).
  1495.  
  1496. Good luck!
  1497.  
  1498. chuck
  1499.  
  1500. +---------------------------------------------------------------------------+
  1501. |      Chuck McMath * Reed Technology and Information Services, Inc.        |
  1502. |       20251 Century Blvd * Germantown, MD 20874 * chuck@ocs.com           |
  1503. |"Hey batter, hey batter, swing!" (Anon) * Jeans by Jordache;Body by Fritos |
  1504. +---------------------------------------------------------------------------+
  1505.  
  1506. ---------------------------
  1507.  
  1508. >From jan.melander@got.wmdata.se (Jan Melander)
  1509. Subject: [Q] Where is the stack?
  1510. Date: Mon, 10 Apr 1995 15:09:08 GMT
  1511. Organization: WM-Data
  1512.  
  1513. Hi,
  1514.  
  1515. In our project we have implemented a trace for memory protection by
  1516. capsule memory operations (alloc, free, memcpy, strncpy....) and do a
  1517. range check when used. I'd like to be able to check if the operation on
  1518. global and local variables is at least within the stack frame, to do that
  1519. I need to know where the stack begins and how large it is.
  1520. I know that certain registers contatins the pointers but I need to access
  1521. them from C and I like to make it work on both 68K and PPC machines.
  1522.  
  1523. Does anybody got any good ideas?
  1524.  
  1525. Cheers,
  1526.  
  1527. -- 
  1528. - -------------------------------------------------------------
  1529.         Jan Melander
  1530.         WM-Data
  1531.         jan.melander@got.wmdata.se
  1532. - -------------------------------------------------------------
  1533. Q:Why didn't Intel name their CPU 586 instead of Pentium?
  1534. A:When they added 100 to 486 the readout said 585.9999999999765,
  1535.   and it didn't fit on the chip.
  1536.  
  1537. +++++++++++++++++++++++++++
  1538.  
  1539. >From DanWr@halcyon.com (Dan Wright)
  1540. Date: Thu, 13 Apr 1995 20:55:34 -0700
  1541. Organization: Northwest Nexus Inc.
  1542.  
  1543. In article <jan.melander-1004951709080001@jmmac.got.wmdata.se>,
  1544. jan.melander@got.wmdata.se (Jan Melander) wrote:
  1545.  
  1546. >Hi,
  1547. >
  1548. >In our project we have implemented a trace for memory protection by
  1549. >capsule memory operations (alloc, free, memcpy, strncpy....) and do a
  1550. >range check when used. I'd like to be able to check if the operation on
  1551. >global and local variables is at least within the stack frame, to do that
  1552. >I need to know where the stack begins and how large it is.
  1553. >I know that certain registers contatins the pointers but I need to access
  1554. >them from C and I like to make it work on both 68K and PPC machines.
  1555. >
  1556. >Does anybody got any good ideas?
  1557. >
  1558.  
  1559. You can do this with inline assembly, but it isn't necessary, and besides
  1560. you want
  1561. it to work on PPC too... this will do the trick:
  1562.  
  1563. /* StackData - return TRUE if pthing is on the stack somewhere */
  1564. Boolean StackData(void *pthing)
  1565. {
  1566.    char topOfStack;
  1567.  
  1568.    return ((Ptr)pthing > &topOfStack && pthing < LMGetCurStackBase());
  1569. }
  1570.  
  1571. Taking the address of a local forces the compiler to store it on the stack
  1572. (not at the
  1573. absolute top, but close enough).
  1574.  
  1575. You can also calculate the top of the stack as:
  1576. (LMGetCurStackBase() - StackSize())
  1577.  
  1578. Incidentally, global variables aren't on the stack. For 68k apps, pthing
  1579. would be 
  1580. greater than LMGetCurStackBase() for globals; in ppc apps, they're at the bottom
  1581. of your heap (subject to change in future versions of system software of
  1582. course).
  1583.  
  1584. On ppc, here's one way to determine whether pthing points to a global:
  1585.  
  1586. #ifdef powerc
  1587.  
  1588. Ptr gPtrLow; // global
  1589.  
  1590. // VERY early in your initialization, do this:
  1591. void main(void)
  1592. {
  1593.    gPtrLow = NewPtr(1);
  1594.    MaxApplZone();
  1595. }
  1596.  
  1597. // then...
  1598. Boolean GlobalData(void *pthing)
  1599. {
  1600.     Ptr *ptv = (Ptr *)GlobalData; 
  1601.     Ptr ptoc = ptv[1];
  1602.     
  1603.     return ((Ptr)pthing > ptoc && (Ptr)pthing < gPtrLow)); 
  1604. }
  1605. #endif // powerc
  1606.  
  1607. Boy, there's a whole trivia contest just lurking in this sample. :-)
  1608.  
  1609. - Dan
  1610.  
  1611. -- 
  1612. Dan Wright
  1613. DanWr@halcyon.com
  1614.  
  1615. ---------------------------
  1616.  
  1617. End of C.S.M.P. Digest
  1618. **********************
  1619.